<?php

//创建zip包
$zip = new ZipArchive();
$zip->open(__DIR__."/1.zip",ZipArchive::CREATE);
$handle = opendir(__DIR__."/cas");
while (false !== $f = readdir($handle)) {
    if ($f == '.' || $f == '..') {
        continue;
    }

    $zip->addFile(__DIR__."/cas/".$f,$f);
}
closedir($handle);

$zip->close();

$filename = "2.zip";
$filepath = __DIR__."/cas";

header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"".$filename."\"");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize(__DIR__."/".$filename));
readfile(__DIR__."/".$filename);
exit();
